package kr.hkit.androidcomplete02.fragment;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class PreCreateDialog extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialogfragment);

	}

	public void mOnClick(View v) {
		DialogFragment newFragment = new DialogFragment();
		newFragment.show(getFragmentManager(), "Dialog");
	}
}

class DialogFragmentEx extends DialogFragment {
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		super.onCreateDialog(savedInstanceState);

		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
		builder.setTitle("알립니다.").setMessage("DialogFragment 를 열었습니다")
				.setPositiveButton("확인", new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						Toast.makeText(getActivity(), "확인 버튼 누름",
								Toast.LENGTH_LONG).show();
					}
				}).setNegativeButton("닫기", null);

		return builder.create();

	}

}
